//+----------------------------------------------------------------------
//| ADM Software [ 我宁可 为做过的事而后悔，也不想 因为没尝试而后悔。 ]
//+----------------------------------------------------------------------
//| Copyright (c) 2014 扬州安蝶梦电子商务有限公司 All rights reserved.
//+----------------------------------------------------------------------
//| Author: 曹梦龙 <138888611@qq.com> <http://www.andiemeng.com>
//+----------------------------------------------------------------------
package com.gr100.biz.kit.bmap;

import java.util.ArrayList;

public class Bounds {
	public double minLng=0;
    public double minLat=0;
    public double maxLng=0;
    public double maxLat=0;
    
    //计算出多边形做大点和最小点坐标
    public Bounds(ArrayList<Point> PointArray){
 
    	for(Point pt : PointArray){
    		//1
    		if(this.minLng==0){
                this.minLng=pt.lng;
            }else{
               if(pt.lng < this.minLng) {
                   this.minLng=pt.lng;
               }
            }
    		//2
    		if(this.minLat==0){
                this.minLat=pt.lat;
            }else{
               if(pt.lat < this.minLat) {
                 this.minLat=pt.lat;
               } 
            }
    		//3
            if(this.maxLng==0){
                this.maxLng=pt.lng;
            }else{
                if(pt.lng > this.maxLng) {
                 this.maxLng=pt.lng;
               } 
            }
            //4
            if(this.maxLat==0){
                this.maxLat=pt.lat;
            }else{
                 if(pt.lat > this.maxLat) {
                 this.maxLat=pt.lat;
                 }
            } 
            
    	}
    }

    //判断点是否在形状之中
    public Boolean isPointInRect(Point point){
    	if(this.minLng <= point.lng && point.lng <=this.maxLng && this.minLat <= point.lat && point.lat<= this.maxLat){
            return true;
        }else{
            return false;
        }
    }
    
    
}
